Passed
Push — depfu/update/npm/lodash-4.17.1... ( 152c97 )
by
unknown
04:58
created

KeyboardsComponent   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 28
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 5

4 Functions

Rating   Name   Duplication   Size   Complexity  
A close 0 3 1
A append 0 4 2
A open 0 4 1
A ngOnInit 0 3 1
1
import { Text } from './../../../assets/data/text.d';
2
import { NameInputComponent } from './../../fragments/name-input/name-input.component';
3
import { KeyboardService } from './../../data/keyboard.service';
4
/**
5
   Copyright 2018 June Hanabi
6
7
   Licensed under the Apache License, Version 2.0 (the "License");
8
   you may not use this file except in compliance with the License.
9
   You may obtain a copy of the License at
10
11
       http://www.apache.org/licenses/LICENSE-2.0
12
13
   Unless required by applicable law or agreed to in writing, software
14
   distributed under the License is distributed on an "AS IS" BASIS,
15
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
   See the License for the specific language governing permissions and
17
   limitations under the License.
18
 */
19
20
import { Component, NgZone, OnInit } from '@angular/core';
21
import { TextService } from '../../data/text.service';
22
23
@Component({
24
    selector: 'app-keyboards',
25
    templateUrl: './keyboards.component.pug',
26
    styleUrls: ['./keyboards.component.scss']
27
})
28
export class KeyboardsComponent implements OnInit {
29
    constructor(
30
        public zone: NgZone,
31
        public ks: KeyboardService,
32
        public ts: TextService
33
    ) { }
34
35
    ngOnInit() {
36
        this.ks.registerKeyboard(this);
37
    }
38
39
    public open(input: NameInputComponent) {
40
        this.opened = true;
41
        this.input = input;
42
    }
43
44
    public close() {
45
        this.opened = false;
46
    }
47
48
    public append(key: Text) {
49
        if (this.input !== null)
50
            this.input.value += key.eng;
51
    }
52
53
    public opened: boolean = false;
54
    public input: NameInputComponent | null = null;
55
}
56